<template>
	<view class="container">
		<uni-list>
			<uni-list-item v-for="item,index in list" :key="index" :title="item.name" :note="item.title"
				clickable="true" :thumbSize="lg" :rightText="item.date" :clickable="true" :showArrow="true"
				@click="toPage(item.id)">
				<template v-slot:footer>
					<uni-badge :text="item.unread" type="error" v-if="item.unread"></uni-badge>
				</template>
			</uni-list-item>
		</uni-list>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: []
			}
		},
		onLoad() {
			uni.showLoading({
				title: '加载中',
				mask: false
			});
			uni.request({
				url: 'http://localhost:8090/freshmenapp/message/list',
				method: 'POST',
				data: {},
				success: res => {
					console.log(res);
					this.list = res.data.list;
					uni.showToast({
						title: '成功'
					});
					setTimeout(() => {
						uni.hideLoading()
					}, 2000)
				},
				fail: () => {
					uni.showToast({
						title: '失败',
						icon: 'none'
					});
				},
				complete: () => {}
			});
		},
		methods: {
			toPage(id) {
				uni.navigateTo({
					url: '/pages/chatdeail/chatdeail?id=' + id,
					success: res => {},
					fail: () => {},
					complete: () => {}
				});
			}
		}
	}
</script>


<style>
	.round {
		width: 80rpx;
		height: 80rpx;
		border-radius: 50%;
		overflow: hidden;
		margin-right: 15rpx;
	}

	.round image {
		width: 100%;
		height: 100%;
	}
</style>